﻿using LibNiconico.NiconicoApi.Extentions;
using LibNiconico.NiconicoApi.Internal.Http;
using LibNiconico.NiconicoApi.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LibNiconico.NiconicoApi.Internal
{
    /// <summary>
    /// URL問い合わせ文字列で取得するニコニコ情報取得API
    /// </summary>
    internal class NiconicoInfoGetApiQueryStringsImpl: NiconicoInfoGetApiImpl
    {
        /// <summary>
        /// コンストラクタ
        /// </summary>
        internal NiconicoInfoGetApiQueryStringsImpl(Uri url, INiconicoHttpClient client) : base(url, client) { }


        /// <summary>
        /// 非同期にGetメソッドで取得
        /// </summary>
        /// <param name="urlAble"></param>
        /// <returns></returns>
        internal protected async Task<NiconicoHttpResponse< QueryStrings>> GetAsync(NicoUrlAble urlAble)
        {
            var response = await base.GetStringAsync(urlAble).ConfigureAwait(false);
            return NiconicoHttpResponse.ConvertContent( QueryStrings.Parse(response.Content),response);
        }


        /// <summary>
        /// 非同期にPostメソッドで取得
        /// </summary>
        /// <param name="postAble"></param>
        /// <returns></returns>
        internal protected async Task<NiconicoHttpResponse<QueryStrings>> PostAsync(NicoUrlEncodedPostAble postAble)
        {
            var response = await base.PostStringAsync(postAble).ConfigureAwait(false);
            return NiconicoHttpResponse.ConvertContent(QueryStrings.Parse(response.Content),response);
        }
    }
}
